package com.spring.sunflower.common

import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.spring.sunflower.R
import com.spring.sunflower.bean.*
import com.spring.sunflower.util.DateTimeUtils
import java.util.*

/**
 * Created by Kevin on 2021/8/28<br/>
 *
 * Describe:<br/>
 */
class ChargeRecordAdapter(layoutResId: Int, data: MutableList<BillListBean.Data>) :
    BaseQuickAdapter<BillListBean.Data, BaseViewHolder>(layoutResId, data) {
    override fun convert(holder: BaseViewHolder, item: BillListBean.Data) {
        holder.setText(
            R.id.tvTitle,
            "充值${item.goldCoin}金币"
        )
        val timeFormatText = DateTimeUtils.getTimeFormatText(Date((item.createTime).toLong()))
        holder.setText(R.id.tvTime, timeFormatText)
        val tvDetail = holder.getView<TextView>(R.id.tvDetail)
        if ((item.goldCoin).toInt() >= 0) {
            tvDetail.setText("+${item.goldCoin}")
            tvDetail.setTextColor(ContextCompat.getColor(context, R.color.colorPrimary))
        } else {
            tvDetail.setText("${item.goldCoin}")
            tvDetail.setTextColor(ContextCompat.getColor(context, R.color.green))
        }


//        val ivMoney: ImageView = holder.getView(R.id.ivMoney)
//        ivMoney.setImageResource(R.drawable.ic_income_diamond)

    }
}